package com.snail.billing.page;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.android.util.ResUtil;
import com.snail.billing.Resource;
import com.snail.billing.os.DialogPage;

public class ServicePage extends DialogPage implements View.OnClickListener {

	private TextView textTitle;
	private View buttonBack;

	private View button1;
	private View button2;

	@Override
	public int createLayoutId() {
		return ResUtil.getLayoutId(Resource.layout.snailbilling_service_activity);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		textTitle = (TextView) findViewById(ResUtil.getViewId(Resource.id.snailbilling_title_text));
		textTitle.setText(ResUtil.getString(Resource.string.snailbilling_service_title));
		buttonBack = findViewById(ResUtil.getViewId(Resource.id.snailbilling_title_button_back));
		buttonBack.setOnClickListener(this);
		//
		button1 = findViewById(ResUtil.getViewId(Resource.id.snailbilling_service_button1));
		button2 = findViewById(ResUtil.getViewId(Resource.id.snailbilling_service_button2));
		button1.setOnClickListener(this);
		button2.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		if (v.equals(buttonBack)) {
			getPageManager().backward();
		} else if (v.equals(button1)) {
			Uri uri = Uri.parse(ResUtil.getString(Resource.string.snailbilling_service_text_number1));
			Intent it = new Intent(Intent.ACTION_DIAL, uri);
			getContext().startActivity(it);
		} else if (v.equals(button2)) {
			Uri uri = Uri.parse(ResUtil.getString(Resource.string.snailbilling_service_text_number2));
			Intent it = new Intent(Intent.ACTION_DIAL, uri);
			((Activity) getContext()).startActivity(it);
		}
	}

}
